package com.hmall.order.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 时间自动填充
 */

@Component
public class MydateHandler implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        //log.info("start insert fill ....");
        //this.strictInsertFill(metaObject, "createTime", LocalDateTime.class, LocalDateTime.now());

        metaObject.setValue("createTime",new Date());
        metaObject.setValue("updateTime",new Date());

    }

    @Override
    public void updateFill(MetaObject metaObject) {
        //log.info("start update fill ....");
        //this.strictUpdateFill(metaObject, "updateTime", LocalDateTime.class, LocalDateTime.now());
        metaObject.setValue("updateTime",new Date());
    }
}
